package com.sztz.utils;

import lombok.Getter;

/**
 * 实验对象锁跟类锁
 * @author yzy
 * @date 2022/10/11 19:48
 */
public class LockDataClass {

    @Getter
    private static int counter = 0;
    private static Object locker = new Object();

    public static void init(){
        counter = 0;
    }

    public synchronized void wrong(){
        counter++;
    }

    public void right(){
        synchronized (locker){
            counter++;
        }
    }
}
